package restaurant.iterators;

import static org.junit.Assert.*;

import java.util.ArrayList;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
 * Test case for the StandardIterator class. Tests to ensure the {@code hasNext}
 * and {@code next} methods work correctly.
 * 
 * @author Odessa
 */
public class StandardIteratorTest
{
	ArrayList<Object> list;
	StandardIterator si;



	/**
	 * Sets up the test fixture.
	 * 
	 * @throws Exception the exception
	 */
	@Before
	public void setUp() throws Exception
	{
		list = new ArrayList<Object>();
	}



	/**
	 * Tears down the test fixture.
	 * 
	 * @throws Exception the exception
	 */
	@After
	public void tearDown() throws Exception
	{
		list.clear();
		si = null;
	}



	/**
	 * Test method for {@link restaurant.iterators.StandardIterator#hasNext()}. Tests
	 * hasNext() if there is another item in the collection.
	 */
	@Test
	public void testHasNext_Yes()
	{
		list.add("Item 1");
		si = new StandardIterator(list);

		assertTrue(si.hasNext());
	}



	/**
	 * Test method for {@link restaurant.iterators.StandardIterator#hasNext()}. Tests
	 * hasNext() if there isn't another item in the collection.
	 */
	@Test
	public void testHasNext_No()
	{
		si = new StandardIterator(list);

		assertFalse(si.hasNext());
	}



	/**
	 * Test method for {@link restaurant.iterators.StandardIterator#next()}. Tests next()
	 * when there is another item in the collection.
	 */
	@Test
	public void testNext_NextExists()
	{
		list.add("Item 1");
		si = new StandardIterator(list);

		assertEquals("Item 1", si.next());
	}



	/**
	 * Test method for {@link restaurant.iterators.StandardIterator#next()}. Tests next()
	 * when there are no more items in the collection.
	 */
	@Test
	public void testNext_NoNextItem()
	{
		si = new StandardIterator(list);

		assertNull(si.next());
	}

}
